
const tokens = {
  admin: {
    token: 'admin-token'
  },
  editor: {
    token: 'editor-token'
  }
}

const users = {
  'admin-token': {
    // roles: ['admin'],
    uid: 123,
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    fullname: 'Super Admin',
    email: 'qq1079265662@163.com'

  }
  // 'editor-token': {
  //   // roles: ['editor'],
  //   introduction: 'I am an editor',
  //   avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  //   name: 'Normal Editor'
  // }
}
module.exports = [
  // user login
  {
    url: '/vue-element-admin/user/login',
    type: 'post',
    response: config => {
      const { username } = config.body
      const token = tokens[username]

      // mock error
      if (!token) {
        return {
          code: 60204,
          message: '账号密码错误'
        }
      }

      return {
        code: 20000,
        data: token
      }
    }
  },

  // get user info
  {
    url: '/vue-element-admin/user/info\.*',
    type: 'get',
    response: config => {
      const { token } = config.query
      const info = users[token]

      // mock error
      if (!info) {
        return {
          code: 50008,
          message: '获取用户信息错误'
        }
      }

      return {
        code: 20000,
        data: info
      }
    }
  },

  // get userRolseList
  // {
  //   url: '/vue-element-admin/user/rolesList\.*',
  //   type: 'get',
  //   response: config => {
  //     const { token } = config.query
  //     const UserrolesList = rolesList[token]
  //     // mock error
  //     if (!token) {
  //       return {
  //         code: 60204,
  //         message: '获取用户路由数据错误'
  //       }
  //     }

  //     return {
  //       code: 20000,
  //       data: UserrolesList
  //     }
  //   }
  // },

  // user logout
  {
    url: '/vue-element-admin/user/logout',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
]
